﻿<%@ WebHandler Language="C#" Class="lists" %>
using Models;
using System;
using System.Web;
using Newtonsoft.Json;
using System.Linq;
using Newtonsoft.Json.Linq;
using System.Collections;


public class lists : IHttpHandler {

    public void ProcessRequest(HttpContext context) {
        context.Response.ContentType = "text/plain";

        string query = HttpContext.Current.Request.Params["page"];


        var code = 1;
        var msg = "获取成功";
        var time = DateTime.Now;

        using (Entities bll = new Entities())
        {

            ArrayList listjson = new ArrayList();


            var data = bll.X_help.OrderByDescending(x=>x.ID).ToList();//全部.ToList();


            foreach (var x in data)
            {
                JArray imgs = (JArray)JsonConvert.DeserializeObject(x.HImges);   
                listjson.Add(new
                {
                    id = x.ID,
                    avatar = _rky.getUimgbyOPID(x.HGuID),
                    username = _rky.getUnamebyOPID(x.HGuID),
                    time = x.HReTime,
                    text = x.HContent,
                    img = imgs,
                    x.latitude,
                    x.longitude,
                    x.chooseAddress

                });


                var total = data.Count();

              

            }
              context.Response.Write(JsonConvert.SerializeObject(new { code, msg, time, data=listjson }));

            HttpContext.Current.Response.End();
            //context.Response.Write("Hello World");


        }
    }

    public bool IsReusable {
        get {
            return false;
        }
    }




}